<template>
	<view>
		<view class="bigBox">
			<view
				class="content"
				v-for="(item, index) in allDataList"
				:key="index"
				@click="particulars(item)"
			>
				<view style="flex: 1">
					<view class="content_title"
						><view>医院：</view><text>{{ item.orgName }}</text></view
					>
					<view class="content_title"
						><view>科室：</view><text>{{ item.deptName }}</text></view
					>
					<view class="content_title"
						><view>时间：</view
						><text>{{ item.appointExecuteTime.split(' ')[0] }}</text></view
					>
					<view class="content_title"
						><view>总费用：</view><text>￥{{ item.totalFee }}</text></view
					>
				</view>
				<view
					class="paymentState"
					:style="{
						color:
							item.chargeFlag == 0
								? nonPayment
								: item.chargeFlag == 1
								? havePiad
								: item.chargeFlag == 2
								? refund
								: ARefundOf,
					}"
					>{{
						item.chargeFlag == 0
							? '未支付'
							: item.chargeFlag == 1
							? '已支付'
							: item.chargeFlag == 2
							? '已退款'
							: '退款中'
					}}</view
				>
			</view>
			<view style="padding-bottom: 80px; margin-top: 10px"
				><u-divider bg-color="#ececec">暂无更多数据</u-divider>
			</view>
		</view>
		<view class="safe"></view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
import { examineOrInspect } from '../../http/api'
import { mapState } from 'vuex'
export default {
	data() {
		return {
			allDataList: [],
			nonPayment: 'orange',
			refund: 'red',
			havePiad: 'green',
			ARefundOf: '#0089ffe0',
		}
	},
	onLoad() {
		wx.showLoading({
			title: '加载中',
			mask: true,
		})
		this.examineOrInspectData('0', this.patientIdentity)
	},
	computed: {
		...mapState({
			patientIdentity: state => state.patientIdentity,
			orgId: state => state.orgId,
		}),
	},
	methods: {
		// type  0：检查、1：检验
		examineOrInspectData(type, idCard) {
			examineOrInspect({ type: type, idCard: idCard, ordId: this.orgId }).then(
				({ data, head }) => {
					if (head.code == 200) {
						wx.showToast({
							title: '加载成功',
						})
						this.allDataList = data
					} else {
						uni.hideLoading()
						this.$refs.uToast.show({
							title: head.msg,
							type: 'error',
							duration: 1500,
						})
					}
				},
			)
		},
		particulars(item) {
			console.log(item.appointExecuteTime)
			this.$router.navigateTo({
				url: `/pages/myExamine/particulars?id=${item.id}&appointExecuteTime=${
					item.appointExecuteTime
				}&itmeParameter=${JSON.stringify(item)}`,
			})
		},
	},
}
</script>

<style lang="scss">
page {
	background: rgb(236, 236, 236);
}
.content {
	display: flex;
	align-items: center;
	margin-bottom: 10px;
	padding: 15px;
	background: #fff;
	font-size: 16px;
	.content_title {
		display: flex;
		padding-left: 20px;
		view {
			min-width: 80px;
		}
	}
}
.paymentState {
	font-size: 36rpx;
	font-weight: bold;
}
.safe {
	height: 0;
	height: constant(safe-area-inset-bottom);
	height: env(safe-area-inset-bottom);
}
</style>